package com.dingup.provider.feign.server.log;

import com.dingup.api.bean.feign.log.LogSaveFeignBean;
import com.dingup.api.bean.feign.log.LogSearchFeignBean;
import com.dingup.api.model.sys.SysLog;
import com.dingup.provider.service.log.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by wancheng on 2018/10/9.
 */
@RestController()
@RequestMapping("/feign/log")
public class LogFeign {

    @Autowired
    SysLogService sysLogService;

    @RequestMapping(value = "/save_log.do", method = RequestMethod.POST)
    public void saveLog(@RequestBody LogSaveFeignBean bean) {
        sysLogService.saveLog(
                bean.getCreateUserId(),
                bean.getUpdateType(),
                bean.getContent(),
                bean.getModelId(),
                bean.getModel());
    }

    @RequestMapping(value = "/get_log.do", method = RequestMethod.POST)
    public List<SysLog> getLog(@RequestBody LogSearchFeignBean logSearchFeignBean) {
        return sysLogService.getLog(
                logSearchFeignBean.getUpdateType(),
                logSearchFeignBean.getModelId(),
                logSearchFeignBean.getModel());
    }
}
